


for k,v in pairs(load_excel('物品数据.xlsx','组装工人')) do
    
    ac.lni('item',k,v)
    ac.item(k)(v)
end


ac.item('升级工作效率'){
    empty_item = true,

    get_gold = function(self,player)
        local player = player or ac.player.self
        return self['消耗金币'] + player:get_data('升级工作',0) * self['累计消耗']
    end,

    on_sell = function(self,unit,player)
        local num = player:get_data('升级工作',0) + 1
        player:set_data('升级工作',num)
        player:set_data('工作效率',player:get_data('工作效率',40) - 1)
        if num==self['升级上限'] then
            local key = ('禁止购买%s'):format(player.id)
            self:set_data(key,true)
        end
        if player:is_self() then
            self.show_num = num
        end
    end,
    on_check = function(self,unit,player)
        local num = player:get_data('升级工作',0)
        return num<self['升级上限']
    end,
    on_add = function(self)
        local unit = self.owner
        local player = unit.owner
        work_load(unit)
        player:set_data('工作效率',50)
        unit.work_timer = unit:loop(1000,function()
            unit:play_animation('attack')
            local load1 = player:get_data('组装进度',0)
            local load2 = player:get_data('工作效率',40)
            local hero = player.hero
            if load1>=load2 then
                player:set_data('组装进度',0)
                if hero then
                    hero:add('钩锁次数',1)
                end
            else
                player:set_data('组装进度',load1 + 1)
            end
        end)
    end
}

